package com.winit.projectPlan.service;

import com.winit.common.base.bean.ExecuteResult;
import com.winit.projectPlan.manager.ProjectPlanMananger;
import com.winit.projectPlan.model.ProjectPlan;
import com.winit.projectPlan.repository.ProjectPlanRepository;
import com.winit.projectPlan.repository.ProjectPlanRepositoryExt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ProjectPlanService implements IProjectPlanService {
    private static Logger log = LoggerFactory.getLogger(ProjectPlanService.class);

    @Autowired
    private ProjectPlanRepository brdRepository;
    @Autowired
    private ProjectPlanRepositoryExt projectPlanRepositoryExt;
    @Autowired
    private ProjectPlanMananger projectPlanMananger;

    @Override
    public ProjectPlan getUndeletedProjectPlanById(String projectPlanId) {
        return this.brdRepository.findByProjectPlanIdAndProjectPlanIsDelNot(projectPlanId, "0");
    }

    @Override
    public ExecuteResult updateProjectPlanById(ProjectPlan projectPlan) {
        ExecuteResult executeResult = new ExecuteResult();
        this.projectPlanRepositoryExt.updateProjectPlanById(projectPlan);
        return executeResult;
    }

    @Override
    public ExecuteResult createProjectPlanForReq(ProjectPlan projectPlan) {
        return this.projectPlanMananger.createProjectPlan(projectPlan);
    }
}
